import api from '../../../services/api'
import {defineStore} from "pinia";
import {Pagination, Record, Sorting, Filters, Prize, Activity} from "../types";


const createPrize = async (prize: Prize) => {
  try {
    const res = await api.post('/admin/lottery/prize/create', prize)
    return res.data.data;
  } catch (err) {
    console.error(err);
  }
  return null;
};

export const usePrizeStore = defineStore('prize', {
  state: () => {
    return {
      items: [] as Record[],
      pagination: {
        page: 1,
        perPage: 10,
        total: 0,
      } as Pagination,
    }
  },

  actions: {
    createPrize: async (prize: Prize) => {
      const res = await createPrize(prize);
      console.log(res)
      return res;
    },
  }
});
